﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankAccount
{
    public partial class Form1 : Form
    { 
        private BankAccount myAccount1, myAccount2, myAccount3, currentAccount;
        ListBox currentListbox;
        public Form1()
        {
            InitializeComponent();
            myAccount1 = new BankAccount(1, "Monica Stoica", 130);
            myAccount2 = new BankAccount(2, "John Doe", 0);
            myAccount3 = new BankAccount(3, "Jane Doe", 75);
            currentAccount = myAccount1;
            currentListbox = lbAccount1;
            
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           

        }

        private void btnDeposit_Click(object sender, EventArgs e)
        {
            currentAccount.deposit(10);
            this.currentListbox.Items.Add(currentAccount.AsAString());
            
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (this.rbtnAccount1.Checked)
            {
                currentAccount = myAccount1;
                currentListbox = lbAccount1;
                this.currentListbox.Items.Add( currentAccount.AsAString());
            }
            else { this.lbAccount1.Items.Clear(); }
              
            }
        
        private void ShowInfo(BankAccount bank, ListBox list)
        {
            list.Text = bank.AsAString();


        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (this.rbtnAccount2.Checked)
            {
                currentAccount = myAccount2;
                currentListbox = lbAccount2;
                this.currentListbox.Items.Add(currentAccount.AsAString() );
            }
                else{this.lbAccount2.Items.Clear();}
            }
        

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (this.rbtnAccount3.Checked)
            {
                currentAccount = myAccount3;
                currentListbox = lbAccount3;
                this.currentListbox.Items.Add(currentAccount.AsAString());
            }
            else
            {
                this.lbAccount3.Items.Clear();}
            }
        

        private void btnWithdraw_Click(object sender, EventArgs e)
        {
            currentAccount.withdraw(10);
            this.currentListbox.Items.Add(currentAccount.AsAString());
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            

        }

        private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }
    }
}
